<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="/foa/public/jquery-3.4.1.min.js"></script>

</head>
<body>
	<br> 消息：
	<br>
	<div id="msg" style="height: 400px; width: 100%; overflow: scroll;"></div>
	<br>
	<br>
	<textarea id="input-msg" style="height: 200px; width: 100%; overflow: scroll;"></textarea>
	<br>
	<button id="btn-send">发送消息</button>

</body>
<script language="javascript">
var requestContext = "foa";
var idUser = "zhangsan";
var url = "/foa/talk/sendMsg.do";
	$(document).ready(
			function() {
				// 发送消息
				$("#btn-send").click(
						function() {
							$("#msg").append(
									new Date() + ":" + idUser + ":<br>"
											+ $("#input-msg").val() + "<br>")

							$.post( url, {
								idUser : idUser,
								content : $("#input-msg").val() //encodeURIComponent($("#input-msg").val())

							}, function(data, status) {
								console.log(data);
								//alert("Data: " + data[0].data + "\nStatus: " + data[0].code);
								for(var i = 0; i < data.length; i++){
									$("#msg").append(
											new Date() + ":" + "小电脑" + ":<br>"
													+ data[i].data + "<br>");
								}
							});
							$("#input-msg").val('');

						});
			});
</script>
</html>